import sqlite3

class A8(object):
    def __init__(self) -> None:
        self.dataBase = 'data.db'
        self.table = 'A8'
        pass

    def execute(self,sql):
        conn = sqlite3.connect(self.dataBase)
        cursor = conn.cursor()
        cursor.execute(sql)
        conn.commit()
        conn.close()
    def query(self,key,value):
        sql = "SELECT * FROM {table} WHERE {key}='{value}'".format(table=self.table,key=key,value=value)
        self.execute(sql)
    def add(self,data):
        sql = "INSERT INTO {table} (time,A1,A2,A3,A4,A5,A6,A7,A8) VALUES ('{time}',{A1},{A2},{A3},{A4},{A5},{A6},{A7},{A8});"\
            .format(table=self.table,time=data[8],A1=data[0],A2=data[1],A3=data[2],A4=data[3],A5=data[4],A6=data[5],A7=data[6],A8=data[7])
        self.execute(sql)
    def delete(self,key,val):
        sql = "DELETE FROM {table} WHERE {key}={val}".format(table=self.table,key=key,val=val)
        self.execute(sql)
